package com.seguriapp.activities;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTabHost;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;

import com.google.android.maps.MapView;
import com.seguriapp.R;
import com.seguriapp.R.drawable;
import com.seguriapp.util.TabManager;

public class EntityActivity extends FragmentActivity {

	FragmentTabHost mTabHost;
	TabManager mTabManager;
	View mMapViewContainer;
	MapView mMapView;
	View mListViewContainer;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_tab_host);
		mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
		mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);
		mTabHost.addTab(
				mTabHost.newTabSpec("lista").setIndicator("Lista",
						getResources().getDrawable(R.drawable.camara_selector)),
				EntityListFragmentActivity.EntityListFragment.class, null);

		mTabHost.addTab(
				mTabHost.newTabSpec("lista2").setIndicator("Mapa",
						getResources().getDrawable(R.drawable.map_selector)),
				EntityMapFragmentActivity.EntityMapFragment.class, null);


		if (savedInstanceState != null) {
			mTabHost.setCurrentTabByTag(savedInstanceState.getString("tab"));
		}
	}

	@Override
	protected void onSaveInstanceState(Bundle outState) {
		super.onSaveInstanceState(outState);
		outState.putString("tab", mTabHost.getCurrentTabTag());
	}

	@Override
	public void onBackPressed() {
		super.onBackPressed();
		overridePendingTransition(R.anim.zoom_enter, R.anim.zoom_exit);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		MenuItem item1 = menu.add(1, 1, 1, "Realidad Aumentada");
		item1.setIcon(drawable.camara_selector);
		return super.onCreateOptionsMenu(menu);
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case 1:
			final Intent aRIntent = new Intent(this, MixViewActivity.class);
			aRIntent.putExtra("dataSource", "entity");
			startActivity(aRIntent);
			break;
		default:
			break;

		}
		return super.onOptionsItemSelected(item);
	}

}
